let f =
    q => {
        return x => {
            if (x === 0) {
                return 1
            } else {
                return x * q(x - 1)
            }
        }
    };

let Y =
    f => {
        let q =
            self => {
                return x => {
                    return f(self(self))(x)
                }
            }
        return q(q)
    };

console.dir(
    Y(f)(4)
);
